#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int N = 1<<17;
const int mod = 998244353;
const int inv2 = (mod+1)/2;

int n,a[N],b[N];
ll f[N],g[N];

void init(){for(int i = 0;i < n;i++) f[i] = a[i],g[i] = b[i];}

void OR(ll *f,int on = 1){
	for(int h = 2;h <= n;h <<= 1)
		for(int j = h >> 1,i = 0;i < n;i+=h)
			for(int k = i;k < i+j;k++)
				(f[k+j] += f[k] * on % mod + mod) %= mod;
}

void AND(ll *f,int on = 1){
	for(int h = 2;h <= n;h <<= 1)
		for(int j = h >> 1,i = 0;i < n;i+=h)
			for(int k = i;k < i+j;k++)
				(f[k] += f[k+j] * on % mod + mod) %= mod;
}

void XOR(ll *f,int on = 1){
	for(int h = 2;h <= n;h <<= 1)
		for(int j = h >> 1,i = 0;i < n;i+=h)
			for(int k = i;k < i+j;k++){
				ll x = f[k],y = f[k+j];
				f[k] = (x + y) % mod,f[k+j] = (x-y+mod) % mod;
				if(on == -1) f[k] = f[k] * inv2 % mod,f[k+j] = f[k+j] * inv2 % mod;
			}
}

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in; n = 1 << n;
	for(int i = 0;i < n;i++) a[i] = in;for(int j = 0;j < n;j++) b[j] = in;
	init(); OR(f); OR(g); for(int i = 0;i < n;i++) f[i] = f[i] * g[i] % mod; OR(f,-1); for(int i = 0;i < n;i++) printf("%lld%c",f[i]%mod," \n"[i==n-1]);
	init(); AND(f);AND(g);for(int i = 0;i < n;i++) f[i] = f[i] * g[i] % mod;AND(f,-1); for(int i = 0;i < n;i++) printf("%lld%c",f[i]%mod," \n"[i==n-1]);
	init(); XOR(f);XOR(g);for(int i = 0;i < n;i++) f[i] = f[i] * g[i] % mod;XOR(f,-1); for(int i = 0;i < n;i++) printf("%lld%c",f[i]%mod," \n"[i==n-1]);
	return 0;
}

